package com.example.myapplication;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class ContactSQLiteOpenHelper extends SQLiteOpenHelper {


    public ContactSQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL("CREATe TABLE contacts(id INTEGER PRIMARY KEY AUTOINCREMENT," +
                "name VARCHAR(16) ,phone VARCHAR(11))");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int i, int i1) {
        if (i1>1){
            db.execSQL("ALTER TABLE contacts ADD notes VARCHAR(20)");
        }
    }
}
